package com.yf.dmp.service;

import com.alibaba.fastjson.JSON;
import com.yf.dmp.bean.MainMenu;
import com.yf.dmp.dao.MenuDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class MenuService {
    @Autowired
    private MenuDao mDao;

    public String getMenu(){
        HashMap<String,Object> data = new HashMap<>();
        List<MainMenu> menu =  mDao.getMenu();
        if (menu!=null){
            data.put("menu",menu);
            data.put("flag",200);
        }else{
            data.put("flag",404);
        }
        String jsonstr = JSON.toJSONString(data);
        System.out.println(jsonstr);
        return jsonstr;
    }
}
